class History {
  String _startTime = "";
  String _endTime = "";
  int _cycle = 28;
  int _period = 5;

  History(this._startTime, this._endTime, this._cycle, this._period);

  int get period => _period;

  set period(int value) {
    _period = value;
  }

  int get cycle => _cycle;

  set cycle(int value) {
    _cycle = value;
  }

  String get endTime => _endTime;

  set endTime(String value) {
    _endTime = value;
  }

  String get startTime => _startTime;

  set startTime(String value) {
    _startTime = value;
  }

  History.fromJson(Map<String, dynamic> json)
      : _startTime = json['startTime'] ?? "",
        _endTime = json['endTime'] ?? "",
        _period = json['period'] ?? 0,
        _cycle = json['cycle'] ?? 0;

  Map<String, dynamic> toJson() => {
        'startTime': _startTime,
        'endTime': _endTime,
        'period': _period,
        'cycle': _cycle
      };
}

class MenstrualRecord {
  int _flowRate = -1;
  int _dysmenorrhea = -1;
  List<int> _symptoms = List.filled(8, 0);
  int _leucorrhea = -1;
  int _mood = -1;
  int _ovulation = -1;
  int _love = -1;
  int _colorRate = -1;
  String _notes = "";
  String _day = "";

  MenstrualRecord(
      this._flowRate,
      this._dysmenorrhea,
      this._symptoms,
      this._leucorrhea,
      this._mood,
      this._ovulation,
      this._love,
      this._colorRate,
      this._notes,
      this._day);

  int get flowRate => _flowRate;

  set flowRate(int value) {
    _flowRate = value;
  }

  int get dysmenorrhea => _dysmenorrhea;

  set dysmenorrhea(int value) {
    _dysmenorrhea = value;
  }

  List<int> get symptoms => _symptoms;

  set symptoms(List<int> value) {
    _symptoms = value;
  }

  int get leucorrhea => _leucorrhea;

  set leucorrhea(int value) {
    _leucorrhea = value;
  }

  int get mood => _mood;

  set mood(int value) {
    _mood = value;
  }

  int get ovulation => _ovulation;

  set ovulation(int value) {
    _ovulation = value;
  }

  int get love => _love;

  set love(int value) {
    _love = value;
  }

  int get colorRate => _colorRate;

  set colorRate(int value) {
    _colorRate = value;
  }

  String get notes => _notes;

  set notes(String value) {
    _notes = value;
  }

  String get day => _day;

  set day(String value) {
    _day = value;
  }

  MenstrualRecord.fromJson(Map<String, dynamic> json)
      : _flowRate = json['flowRate'] ?? -1,
        _dysmenorrhea = json['dysmenorrhea'] ?? -1,
        _symptoms = json['symptoms'] is List<dynamic>
            ? (json['symptoms'] as List<dynamic>).map((item) => item as int).toList()
            : List.filled(8, 0),
        _leucorrhea = json['leucorrhea'] ?? -1,
        _mood = json['mood'] ?? -1,
        _ovulation = json['ovulation'] ?? -1,
        _love = json['love'] ?? -1,
        _colorRate = json['colorRate'] ?? -1,
        _notes = json['notes'] ?? "",
        _day = json['day'] ?? "";

  Map<String, dynamic> toJson() => {
    'flowRate': _flowRate,
    'dysmenorrhea': _dysmenorrhea,
    'symptoms': _symptoms,
    'leucorrhea': _leucorrhea,
    'mood': _mood,
    'ovulation': _ovulation,
    'love': _love,
    'colorRate': _colorRate,
    'notes': _notes,
    'day': _day
  };
}
